# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=diffutils
pkgver=3.6
pkgrel=1
pkgdesc="Utility programs used for creating patch files"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/diffutils"
license=('GPL3')
groups=('base-devel')
depends=('msys2-runtime' 'sh')
install=diffutils.install
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.xz{,.sig}
        diffutils-3.3-msys2.patch)
sha256sums=('d621e8bdd4b573918c8145f7ae61817d1be9deb4c8d2328a65cea8e11d783bd6'
            'SKIP'
            'd58d5ee8c7b889a5027a43ce6d7f4ff5fc3d8927e389290c347ee9be094f6242')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/diffutils-3.3-msys2.patch

  autoreconf -fi
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}

  # make sure tests are running OK
  sed -i "s/mkdir -m 0700/mkdir /" tests/init.sh

  ./configure --build=${CHOST} \
    --prefix=/usr \
    --without-libiconv-prefix \
    --without-libintl-prefix
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
}
